package com.victor.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.victor.dao.CommentsPhotoDao;
import com.victor.dao.PersonaltravelDao;
import com.victor.dao.TravelCollectionDao;
import com.victor.dao.TravelCommentsDao;
import com.victor.dao.TravelDao;
import com.victor.dao.TravelFocusDao;
import com.victor.dao.TravelPraiseDao;
import com.victor.dao.TravelReplyDao;
import com.victor.entity.CommentsPhoto;
import com.victor.entity.Personaltravel;
import com.victor.entity.Travel;
import com.victor.entity.TravelCollection;
import com.victor.entity.TravelComments;
import com.victor.entity.TravelFocus;
import com.victor.entity.TravelPraise;
import com.victor.entity.TravelReply;
import com.victor.entity.User;
import com.victor.service.TravelService;

@Service
public class TravelServiceImpl implements TravelService {
	@Autowired
	private PersonaltravelDao personaltravelDao;
	@Autowired
	private TravelCommentsDao travelcommentsDao;
	@Autowired
	private CommentsPhotoDao commentsphotoDao;
	@Autowired
	private TravelDao travelDao;
	@Autowired
	private TravelFocusDao focusDao;
	@Autowired
	private TravelPraiseDao praiseDao;
	@Autowired
	private TravelCollectionDao collectionDao;
	@Autowired
	private TravelCommentsDao commnetsDao;
	@Autowired
	private TravelReplyDao replyDao;

	@Override
	public PageInfo<Personaltravel> selAll(int page, int row) {
		PageHelper.startPage(page, row);
		List<Personaltravel> list = personaltravelDao.selAll();
		return new PageInfo<>(list, 5);
	}

	@Override
	public Personaltravel selPersontravelById(Integer id) {
		return personaltravelDao.selById(id);
	}

	@Override
	public PageInfo<Personaltravel> selPersontravelByName(String name,int page,int row) {
		PageHelper.startPage(page, row);
		List<Personaltravel> list = personaltravelDao.selByName(name);
		return new PageInfo<>(list, 5);
	}

	@Override
	public boolean delPersontravel(int[] ids) {
		return personaltravelDao.deleteByPrimaryKey(ids);
	}

	@Override
	public List<TravelComments> selCommentsphotoByTravelId(int i) {
		return travelcommentsDao.selByTravelId(i);
	}

	@Override
	public List<CommentsPhoto> selCommentsphotoByTcId(int i) {
		return commentsphotoDao.selByTcid(i);
	}

	@Override
	public boolean delComments(int[] ids) {
		return travelcommentsDao.deleteByPrimaryKey(ids);
	}

	@Override
	public List<Personaltravel> selAllNoPage() {
		return personaltravelDao.selAll();
	}

	@Override
	public PageInfo<Personaltravel> selByTime(String start, String end, int page, int row) {
		PageHelper.startPage(page, row);
		List<Personaltravel> list = personaltravelDao.selByTime(start,end);
		return new PageInfo<>(list, 5);
	}

	@Override
	public PageInfo<Personaltravel> selAllByUid(int page, int row, String uid) {
		PageHelper.startPage(page, row);
		List<Personaltravel> list = personaltravelDao.selAllByUid(uid);
		return new PageInfo<>(list, 5);
	}

	@Override
	public User selUserByUserId(String userid) {
		return personaltravelDao.selUserByUserId(userid);
	}

	@Override
	public User selUserByUid(String uid, String userid) {
		return personaltravelDao.selUserByUid(userid,uid);
	}

	@Override
	public PageInfo<Personaltravel> selTravelBUserId(String userid, int page, int row) {
		PageHelper.startPage(page, row);
		List<Personaltravel> list = personaltravelDao.selTravelByUserId(userid);
		return new PageInfo<>(list, 5);
	}

	@Override
	public PageInfo<Personaltravel> selTravelBUid(String uid, String userid, int page, int row) {
		PageHelper.startPage(page, row);
		List<Personaltravel> list = personaltravelDao.selTravelByuid(userid,uid);
		return new PageInfo<>(list, 5);
	}

	@Override
	public boolean insertTravel(Personaltravel personaltravel) {
		return personaltravelDao.insertSelective(personaltravel);
	}

	@Override
	public boolean insertPhoto(Travel travel) {
		return travelDao.insertSelective(travel);
	}

	@Override
	public TravelFocus selByUidAndPid(TravelFocus travelFocus) {
		return focusDao.selByUidAndPid(travelFocus);
	}

	@Override
	public boolean insertFocus(TravelFocus travelFocus) {
		return focusDao.insertSelective(travelFocus);
	}

	@Override
	public boolean delFocus(Integer id) {
		return focusDao.deleteByPrimaryKey(id);
	}

	@Override
	public TravelPraise selPraiseByUidAndTravelid(TravelPraise travelPraise) {
		return praiseDao.selByUidAndTravelId(travelPraise);
	}

	@Override
	public boolean insertPraise(TravelPraise travelPraise) {
		return praiseDao.insertSelective(travelPraise);
	}

	@Override
	public boolean delPraise(Integer id) {
		return praiseDao.deleteByPrimaryKey(id);
	}

	@Override
	public String selPraiseCount(String travelid) {
		return praiseDao.selCountPraise(travelid);
	}

	@Override
	public TravelCollection selCollectionByUidAndTravelid(TravelCollection collection) {
		return collectionDao.selByUidAndTravelid(collection);
	}

	@Override
	public boolean insertCollection(TravelCollection collection) {
		return collectionDao.insertSelective(collection);
	}

	@Override
	public boolean delCollection(Integer id) {
		return collectionDao.deleteByPrimaryKey(id);
	}

	@Override
	public boolean insertComments(TravelComments comments) {
		return commnetsDao.insertSelective(comments);
	}

	@Override
	public boolean insertCommentsPhoto(CommentsPhoto commentsPhoto) {
		return commentsphotoDao.insertSelective(commentsPhoto);
	}

	@Override
	public boolean insertReply(TravelReply reply) {
		return replyDao.insertSelective(reply);
	}

	@Override
	public Personaltravel selDetailsUp(String travelid) {
		return personaltravelDao.selDatailsUp(travelid);
	}

	@Override
	public Personaltravel selDetailsUpByUid(String travelid, String uid) {
		return personaltravelDao.selDatailsUpByUid(travelid,uid);
	}

	@Override
	public PageInfo<TravelComments> selDetailsDown(String travelid,int page,int row) {
		PageHelper.startPage(page, row);
		List<TravelComments> list = commnetsDao.selAppByTravelid(travelid);
		return new PageInfo<>(list, 5);
	}





}
